package lookas;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

import lookas.foto.FotoPosition;
import lookas.trip.Trip;
import lookas.xml.XML;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Optymalizacja{
    private static final Log log = LogFactory.getLog(Optymalizacja.class);

    public static void main(String[] args) throws Exception{
        TimeZone.setDefault(TimeZone.getTimeZone("GMT+1"));
        Trip trip = new Trip("c:\\jfoto\\iGO_backup.db");
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar parse = Calendar.getInstance();
        parse.setTime(format.parse("2007-09-23 11:10:21"));
        File gps = new File("c:\\jfoto\\DSCF3349.jpg");
        Calendar readDate = FotoPosition.readDate(gps);
        int delta = (int)(parse.getTimeInMillis() - readDate.getTimeInMillis());
        trip.setDelta(delta);
        trip.addFotos(new File("c:\\jfoto\\gps"));
        trip.writeFotoGPS();
        //trip.setParrentDir("c:\\jfoto\\gps\\gps\\");
        XML.save(trip.getXMLDocument(), null, "c:\\przed.xml");
        trip.optimalize(1);
        XML.save(trip.getXMLDocument(), "kml", "c:\\po.kml");
        log.info("ok");
    }
}
